package cn.hm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.jms.Topic;

/**
 * @author Mxb
 * @version 1.0
 * @date 2020/8/1 11:40
 */
@RestController
@RequestMapping("/msg")
public class MsgController {

    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    @Autowired
    private Topic topic;


    @RequestMapping("/send")
    public String send(String msg) {
        jmsMessagingTemplate.convertAndSend(topic, msg);
        return "topic发送成功：" + Thread.currentThread().getName();
    }
}
